#include "HttpRequestMethod.h"

CString WH::RequestMethodToString(EHttpRequestMethod Method)
{
    switch(Method)
    {
        case EHttpRequestMethod::GET:
        {
            return U"GET";
        }
        case EHttpRequestMethod::POST:
        {
            return U"POST";
        }
        case EHttpRequestMethod::PUT:
        {
            return U"PUT";
        }
        case EHttpRequestMethod::DELETE:
        {
            return U"DELETE";
        }
        case EHttpRequestMethod::HEAD:
        {
            return U"HEAD";
        }
        case EHttpRequestMethod::OPTIONS:
        {
            return U"OPTIONS";
        }
        case EHttpRequestMethod::PATCH:
        {
            return U"PATCH";
        }
        case EHttpRequestMethod::TRACE:
        {
            return U"TRACE";
        }
        case EHttpRequestMethod::CONNECT:
        {
            return U"CONNECT";
        }
        default:
        {
            assert(false&& "unimplemented method");
            return U"";
        }

    }
}


EHttpRequestMethod  WH::StringToRequestMethod(const CString& InString)
{
    if(InString==U"GET")
    {
        return EHttpRequestMethod::GET;
    }
    else if(InString==U"POST")
    {
        return EHttpRequestMethod::POST;
    }
    else if(InString==U"PUT")
    {
        return EHttpRequestMethod::PUT;
    }
    else if(InString==U"DELETE")
    {
        return EHttpRequestMethod::DELETE;
    }
    else if(InString==U"HEAD")
    {
        return EHttpRequestMethod::HEAD;
    }
    else if(InString==U"OPTIONS")
    {
        return EHttpRequestMethod::OPTIONS;
    }
    else if(InString==U"PATCH")
    {
        return EHttpRequestMethod::PATCH;
    }
    else if(InString==U"TRACE")
    {
        return EHttpRequestMethod::TRACE;
    }
    else if(InString==U"CONNECT")
    {
        return EHttpRequestMethod::CONNECT;
    }
    else
    {
        assert(false&& "unimplemented method");
        return EHttpRequestMethod::GET;
    }
}